<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Basic usage</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sdo.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sdo.sample.getset.html">Setting and Getting Property Values</a></div>
 <div class="up"><a href="sdo.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="sdo.examples-basic" class="section">
  <h2 class="title">Basic usage</h2>
  <p class="para">
   The examples below assume an SDO created with the schema
   and instance information shown below, using the XML Data Access Service.
  </p>
  <p class="para">
   The instance document below describes a single company, 
   called &#039;MegaCorp&#039;, which contains a single department, 
   called &#039;Advanced Technologies&#039;.
   The Advanced Technologies department contains three employees.
   The company employeeOfTheMonth is referencing the second employee,
   &#039;Jane Doe&#039;.
  </p>
  <p class="para">
   <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt; 
&lt;company xmlns=&quot;companyNS&quot; name=&quot;MegaCorp&quot; 
  employeeOfTheMonth=&quot;E0003&quot;&gt;
  &lt;departments name=&quot;Advanced Technologies&quot; location=&quot;NY&quot; number=&quot;123&quot;&gt;
    &lt;employees name=&quot;John Jones&quot; SN=&quot;E0001&quot;/&gt;
    &lt;employees name=&quot;Jane Doe&quot; SN=&quot;E0003&quot;/&gt;
    &lt;employees name=&quot;Al Smith&quot; SN=&quot;E0004&quot; manager=&quot;true&quot;/&gt;
  &lt;/departments&gt;
&lt;/company&gt;</pre>
</div>
   </div>

  </p>
  <p class="para"> The root element of the schema is a company. The company contains departments, and
   each department contains employees. Each element has a number of attributes to store
   things like name, serial number, and so on. Finally, the company also has an IDREF
   attribute which identifies one of the employees as the &#039;employeeOfTheMonth&#039;.
  </p>
  <p class="para">
   <div class="example-contents">
<div class="xmlcode"><pre class="xmlcode">&lt;xsd:schema  
  xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
  xmlns:sdo=&quot;commonj.sdo&quot;
  xmlns:sdoxml=&quot;commonj.sdo/xml&quot;
  xmlns:company=&quot;companyNS&quot;
  targetNamespace=&quot;companyNS&quot;&gt;
  &lt;xsd:element name=&quot;company&quot; type=&quot;company:CompanyType&quot;/&gt;
  &lt;xsd:complexType name=&quot;CompanyType&quot;&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name=&quot;departments&quot; type=&quot;company:DepartmentType&quot; 
        maxOccurs=&quot;unbounded&quot;/&gt;
    &lt;/xsd:sequence&gt;
    &lt;xsd:attribute name=&quot;name&quot; type=&quot;xsd:string&quot;/&gt;
    &lt;xsd:attribute name=&quot;employeeOfTheMonth&quot; type=&quot;xsd:IDREF&quot; 
      sdoxml:propertyType=&quot;company:EmployeeType&quot;/&gt; 
  &lt;/xsd:complexType&gt;
  &lt;xsd:complexType name=&quot;DepartmentType&quot;&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name=&quot;employees&quot; type=&quot;company:EmployeeType&quot;  
        maxOccurs=&quot;unbounded&quot;/&gt;
    &lt;/xsd:sequence&gt;
    &lt;xsd:attribute name=&quot;name&quot; type=&quot;xsd:string&quot;/&gt;
    &lt;xsd:attribute name=&quot;location&quot; type=&quot;xsd:string&quot;/&gt;
    &lt;xsd:attribute name=&quot;number&quot; type=&quot;xsd:int&quot;/&gt;
  &lt;/xsd:complexType&gt;
  &lt;xsd:complexType name=&quot;EmployeeType&quot;&gt;
    &lt;xsd:attribute name=&quot;name&quot; type=&quot;xsd:string&quot;/&gt;
    &lt;xsd:attribute name=&quot;SN&quot; type=&quot;xsd:ID&quot;/&gt;
    &lt;xsd:attribute name=&quot;manager&quot; type=&quot;xsd:boolean&quot;/&gt;
  &lt;/xsd:complexType&gt;
&lt;/xsd:schema&gt;</pre>
</div>
   </div>

  </p>
  <p class="para">The XML Data Access Service maps the schema to an SDO. Attributes such as &quot;name&quot;
   become primitive properties, the sequence of employees becomes a many-valued
   containment relationship, and so on. Note that the containment relationships are
   expressed as one complex type within another, whereas non-containment references are
   expressed in terms of ID and IDREF, with a special
   <strong class="command">sdoxml:propertyType</strong> attribute specifying the type of the
   non-containment reference.
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="sdo.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="sdo.sample.getset.html">Setting and Getting Property Values</a></div>
 <div class="up"><a href="sdo.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
